import 'package:edu_assistant/generated/json/base/json_convert_content.dart';
import 'package:edu_assistant/model/media_item_entity.dart';

MediaItemEntity $MediaItemEntityFromJson(Map<String, dynamic> json) {
  final MediaItemEntity mediaItemEntity = MediaItemEntity();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    mediaItemEntity.id = id;
  }
  final String? mediaUrl = jsonConvert.convert<String>(json['mediaUrl']);
  if (mediaUrl != null) {
    mediaItemEntity.mediaUrl = mediaUrl;
  }
  final String? mediaName = jsonConvert.convert<String>(json['mediaName']);
  if (mediaName != null) {
    mediaItemEntity.mediaName = mediaName;
  }
  final String? mediaImage = jsonConvert.convert<String>(json['mediaImage']);
  if (mediaImage != null) {
    mediaItemEntity.mediaImage = mediaImage;
  }
  return mediaItemEntity;
}

Map<String, dynamic> $MediaItemEntityToJson(MediaItemEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['mediaUrl'] = entity.mediaUrl;
  data['mediaName'] = entity.mediaName;
  data['mediaImage'] = entity.mediaImage;
  return data;
}

extension MediaItemEntityExtension on MediaItemEntity {
  MediaItemEntity copyWith({
    int? id,
    String? mediaUrl,
    String? mediaName,
    String? mediaImage,
  }) {
    return MediaItemEntity()
      ..id = id ?? this.id
      ..mediaUrl = mediaUrl ?? this.mediaUrl
      ..mediaName = mediaName ?? this.mediaName
      ..mediaImage = mediaImage ?? this.mediaImage;
  }
}